/*
*			高级抽象端口类
*/

#pragma once

#include "CxType.h"
#include "CxPackageData.h"
#include <boost/noncopyable.hpp>
#include <boost/asio.hpp>
#include <boost/signals2.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>


namespace ImitateTansfer
{
	using	boost::noncopyable;
	using	boost::signals2::signal;
	struct	CxPort :public	noncopyable 
	{
		virtual		~CxPort(){}

		virtual		bool	OpenPort(LPCSTR		portname)=0;

		virtual		bool	ClosePort()=0;

		virtual		bool	IsOpen()const=0;

		virtual		UINT	GetStatus()const=0;

		virtual		size_t	ReadPort(BYTE *,size_t)=0;				//直读端口
		virtual		size_t	ReadPort(BYTE *,
									size_t ,
									const boost::function<void (const boost::system::error_code& error ,
																size_t bytes_transferred) > &
									)=0;
		virtual		size_t	WritePort(BYTE *,size_t )=0;			//直写端口
		virtual		size_t  WritePort(CxPackage *)=0;
        boost::signals2::signal<void()>		sig_close;

	};
}
